﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Text;

namespace LiaoChengFei.DoMain
{
   public class LiaoChengFeiDbContext:DbContext
    {
        public LiaoChengFeiDbContext(DbContextOptions options) :base(options)
        {

        }

        public DbSet<Orders>  Orders { get; set; }
        public DbSet<VarietyOfDishes>  VarietyOfDishes { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Orders>()
                .HasOne(o => o.VarietyOfDishes)
                .WithMany(v => v.Orders)
                .HasForeignKey(p => p.OrderType);
        }
    }
}
